package com.hitqz.robot.driver.zmq.protocol.handler;

import cn.hutool.core.collection.CollUtil;
import com.example.tutorial.AddressBookProtos;
import com.hitqz.robot.driver.util.WheelCacheUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Objects;
import java.util.Optional;
import java.util.Set;

/**
 * Void数据类型处理类
 *
 * @author wengyx
 * @date 2021-09-13 16:37
 **/
@Slf4j
@Component
public class VoidHandler implements HandlerZMQService {


    @Override
    public void handlerMsg(String robotSn, byte[] data) throws Exception {
        AddressBookProtos.Void aVoid = AddressBookProtos.Void.parseFrom(data);
        int objId = aVoid.getHeader().getObj();
        switch (objId) {
            // 心跳 主动上报 3s左右
            case AddressBookProtos.Void.OBJ_ID.NUL_HEARTBEAT_NTF_VALUE->{
                WheelCacheUtil.put(WheelCacheUtil.KEY_HEART_BEAT, System.currentTimeMillis());
            }
            // 自由导航 目标点到达通知
            case AddressBookProtos.Void.OBJ_ID.NUL_GOAL_REACH_NTF_VALUE->{
                log.info("目标点到达");
            }
        }
    }



}
